//<my-matriculator - a simple tool for registering racers in a USAC cyclocross race>
//Copyright (C) <2011>  <Steven Rivers>

//This program is free software: you can redistribute it and/or modify
//it under the terms of the GNU General Public License as published by
//the Free Software Foundation, either version 3 of the License, or
//(at your option) any later version.

//This program is distributed in the hope that it will be useful,
//but WITHOUT ANY WARRANTY; without even the implied warranty of
//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//GNU General Public License for more details.

//You should have received a copy of the GNU General Public License
//along with this program.  If not, see <http://www.gnu.org/licenses/>.

using System.ComponentModel;

namespace Registration.Model.Entities
{
    public class Entry : INotifyPropertyChanged
    {
        private int _entryid;
        public int EntryId
        {
            get { return _entryid; }
            set
            {
                _entryid = value;
                OnPropertyChanged(new PropertyChangedEventArgs("Bib"));
            }
        }

        private int _bib;
        public int Bib
        {
            get { return _bib; }
            set
            {
                _bib = value;
                OnPropertyChanged(new PropertyChangedEventArgs("Bib"));

            }
        }
        private int _license;
        public int License
        {
            get { return _license; }
            set
            {
                _license = value;
                OnPropertyChanged(new PropertyChangedEventArgs("License"));

            }
        }
        private string _categoryname;
        public string CategoryName
        {
            get { return _categoryname; }
            set { _categoryname = value; OnPropertyChanged(new PropertyChangedEventArgs("CategoryName")); }
        }

        private int _categoryid;
        public int Category
        {
            get { return _categoryid; }
            set
            {
                _categoryid = value;
                OnPropertyChanged(new PropertyChangedEventArgs("Field"));

            }
        }
        private string _fname;
        public string FirstName
        {
            get { return _fname; }
            set
            {
                _fname = value;
                OnPropertyChanged(new PropertyChangedEventArgs("FirstName"));

            }
        }
        private string _lname;
        public string LastName
        {
            get { return _lname; }
            set
            {
                _lname = value;
                OnPropertyChanged(new PropertyChangedEventArgs("LastName"));

            }
        }

        private string _club;
        public string Club
        {
            get { return _club; }
            set { _club = value; OnPropertyChanged(new PropertyChangedEventArgs("Club")); }
        }

        private string _gender;
        public string Gender
        {
            get { return _gender; }
            set { _gender = value; OnPropertyChanged(new PropertyChangedEventArgs("Gender")); }
        }

        private string _age;
        public string Age
        {
            get { return _age; }
            set { _age = value; OnPropertyChanged(new PropertyChangedEventArgs("Age")); }
        }

        public event PropertyChangedEventHandler PropertyChanged;
       
        public void OnPropertyChanged(PropertyChangedEventArgs e)
        {
            if (PropertyChanged != null)
                PropertyChanged(this, e);
        }

        public override bool Equals(object obj)
        {
            if (ReferenceEquals(null, obj)) return false;
            if (ReferenceEquals(this, obj)) return true;
            if (obj.GetType() != typeof (Entry)) return false;
            return Equals((Entry) obj);
        }

        public Entry(int eid, int bib, int license, int catid, string catname, string fname, string lname, string club, string gender, string age)
        {
            EntryId = eid;
            Bib = bib;
            License = license;
            Category = catid;
            CategoryName = catname;
            FirstName = fname;
            LastName = lname;
            Club = club;
            Gender = gender;
            Age = age;
        }

        public bool Equals(Entry other)
        {
            if (ReferenceEquals(null, other)) return false;
            if (ReferenceEquals(this, other)) return true;
            return other._entryid == _entryid && other._bib == _bib && other._license == _license && Equals(other._categoryname, _categoryname) && other._categoryid == _categoryid && Equals(other._fname, _fname) && Equals(other._lname, _lname) && Equals(other._club, _club) && Equals(other._gender, _gender) && Equals(other._age, _age);
        }

        public override int GetHashCode()
        {
            unchecked
            {
                int result = _entryid;
                result = (result*397) ^ _bib;
                result = (result*397) ^ _license;
                result = (result*397) ^ (_categoryname != null ? _categoryname.GetHashCode() : 0);
                result = (result*397) ^ _categoryid;
                result = (result*397) ^ (_fname != null ? _fname.GetHashCode() : 0);
                result = (result*397) ^ (_lname != null ? _lname.GetHashCode() : 0);
                result = (result*397) ^ (_club != null ? _club.GetHashCode() : 0);
                result = (result*397) ^ (_gender != null ? _gender.GetHashCode() : 0);
                result = (result*397) ^ (_age != null ? _age.GetHashCode() : 0);
                return result;
            }
        }
    }
}